package keye.document_manage.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;

public class RowHeaderTable {

	public RowHeaderTable() {
		
	}

	public static JTable getTable(){
		return getTable(new Dimension(30, 30));
	}
	
	public static JTable getTable(Dimension size){
		JTable rowHeaderTable = new JTable (){
			private static final long serialVersionUID = 1L;

			@Override
			public Component prepareRenderer(TableCellRenderer renderer,
					int row, int column) {
				Component component = super.prepareRenderer(renderer, row, column);
				((JLabel)component).setHorizontalAlignment(JLabel.CENTER);
				((JLabel)component).setBackground(new Color(238, 238, 238));
				((JLabel)component).setBorder(UIManager.getBorder("TableHeader.cellBorder"));
				((JLabel)component).setText((row )+"");
				return component;
			}
		};
		rowHeaderTable.setModel(new MyTableModel(
				new Object[]{""},0
				) {
			private static final long serialVersionUID = 1L;
			Class<?>[] columnTypes = new Class[] {
					JLabel.class
			};
			public Class<?> getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
			@Override
			public boolean isCellEditable(int row, int column) {
				// TODO Auto-generated method stub
				return false;
			}
		});
		rowHeaderTable.setRowHeight(30);
		rowHeaderTable.setPreferredScrollableViewportSize(size);
		rowHeaderTable.setEnabled(false);
		return rowHeaderTable;
	}
	
}
